<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <!-- canvas 标签 -->
    <!-- 1. 创建 canvas 标签. 不建议使用 css 控制宽高 -->
    <canvas id="huabu" width="500" height="400"></canvas>

    <script>
        //2. 获取 canvas 元素
        let canvas = document.querySelector('#huabu');

        //3. 设置宽高
        canvas.width = 800;
        canvas.height = 400;

        //4. 创建画笔对象
        let ctx = canvas.getContext('2d');

        //5. 开始绘制
        ctx.beginPath(); // begin 开始  path 路径

        //6. 移动画笔
        ctx.moveTo(100, 50); // move 移动  to 去哪儿

        //7. 绘制线条
        ctx.lineTo(300, 400);
        ctx.lineTo(300, 50);
        ctx.lineTo(100, 50)

        //8. 描边
        ctx.stroke();

    </script>
    <!--  -->

    
</body>
</html>